<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>资源管理</title>
    <#include "/pubHeadStyleTree.html">
    <link rel="stylesheet" href="${ctx}/css/form.css">
</head>
<body>
<div style="position: relative;height: 534px">
    <div class="resShowHide">
        <div style="width: 100%;background:#ccc;height: 30px;line-height: 30px ;">资源管理</div>
        <div class="ccpui-trees" style="top:40px">
                    <p class="isShowTree colorSwitch">
                        <span style="float: left;color: #fff">&nbsp;&nbsp;资源树</span>
                        <i layadmin-event="treeFlexible" class="layui-icon layui-icon-prev"></i>
                    </p>
                    <div style="margin-top: 6px;">
                        <ul class="ccpui-iconTree iconTrees">
                            <li><a class="iconfont iconshuaxin- zTrees-refresh" title="刷新"></a></li>
                            <li><a class="iconfont iconwenjianjia1-copy zTrees-triangle-d" title="展开"></a></li>
                            <li><a class="iconfont iconfolder1 zTrees-triangle-r" title="收起"></a></li>
                            <input type="text" style="width: 50%" class="resZtreeValues">
                        </ul>
                        <ul id="treeSelectResource" class="ztree" style="background: #fff"></ul>
                    </div>
        </div>
        <div class="ccpui-coreContent" style="top:40px" id="menuViewInformation">
        </div>
    </div>
</div>
<div class="nodeSorting" hidden style="display: none">
    <div class="selcetData">
        <table style="width:100%">
            <tr>
                <td class="right">
                    <select class="rightData" multiple="multiple" style="margin-top: 10px">
                    </select>
                </td>
                <td class="left">
                    <span class="layui-btn moveTop">顶部</span>
                    <span class="layui-btn moveUp">向上</span>
                    <span class="layui-btn moveDown">向下</span>
                    <span class="layui-btn moveBottom">底部</span>
                </td>
            </tr>
        </table>
    </div>
    <div style="margin: 15px;text-align: center">
        <button class="layui-btn" lay-filter="resAddeditForm">保存</button>
        <button class="layui-btn cancelNodeSorting layui-btn-danger">取消</button>
    </div>
</div>
<div class="menuGenDetermine" hidden style="display: none">
    <p style="margin: 10px">将生成如下菜单</p>
    <div id="menuGenDetermine"></div>
    <div style="text-align:right ;margin: 10px">
        <button class="layui-btn saveMenus">确定</button>
    </div>
</div>
<input type="hidden" id="resIdSelect">
<input type="hidden" id="resParentId">
<input type="hidden" id="orgIdSelect">

<script>
    var selectResId = "";//资源树id
    layui.config({
        base: serverPath.formPath + staticPath.formPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index', 'table', 'layer', 'form', 'setter', 'upload', 'commons'], function () {
        var table = layui.table, layer = layui.layer, form = layui.form, $ = layui.jquery,
            setter = layui.setter, upload = layui.upload, commons = layui.commons;
        form.render();
        $('body > .importResources').remove();
        $('body').append($('.importResources'));
        $('body > .nodeSorting').remove();
        $('body').append($('.nodeSorting'));
        $('body > .menuGenerations').remove();
        $('body').append($('.menuGenerations'));
        $('body > .menuGenDetermine').remove();
        $('body').append($('.menuGenDetermine'));
        var formKey = '${formKey}';
        resZtrees();
        layui.resZteeRef = function () {
            resZtrees();
        };

        function resZtrees() {
             var setting = {
                        view: {
                            showLine: true,
                            nameIsHTML: true, //允许name支持html
                            selectedMulti: false,
                            showIcon: showIconForTree
                        },
                        edit: {
                            enable: false,
                            editNameSelectAll: false
                        },
                        data: {
                            simpleData: {
                                enable: true,
                                idKey: "resId",
                                pIdKey: "parentId"
                            }
                        },
                        async: {
                            enable: true,
                            type:'get',
                            dataType:'json',
                            url:serverPath.formPath + setter.sysLinkPath + "sysRes/getSystemTreeData",
                            autoParam:["resId"]
                        },
                        callback: {
                            onClick: onClickResouse
                        }
                    };
                    $.fn.zTree.init($("#treeSelectResource"), setting);
                    component.fuzzySearch('treeSelectResource', '.resZtreeValues', null, true); //初始化模糊搜索方法

            function showIconForTree(treeId, treeNode) {
                return treeNode.iconSkin==null;
            };
        }

        function onClickResouse(event, treeId, treeNode) {
            selectResId= treeNode.resId;
        }

        function hideRMenu() {
            if ($("#resRightMenus")) $("#resRightMenus").css({"visibility": "hidden"});
            $("body").unbind("mousedown", onBodyMouseDown);
        }

        function onBodyMouseDown(event) {
            if (!(event.target.id == "orgRightMenu" || $(event.target).parents("#resRightMenus").length > 0)) {
                $("#resRightMenus").css({"visibility": "hidden"});
            }
        }
        $('#menuViewInformation').load(serverPath.formPath + setter.formLinkPath +'formDef/view/resAdd?resId='+selectResId+"&formKey="+formKey);

        $(".cancelNodeSorting").click(function () {
            layer.close(nodeSors);
        });

        //展开
        $(".iconTrees .zTrees-triangle-d").click(function () {
            $.fn.zTree.getZTreeObj("treeSelectResource").expandAll(true);
        });
        //收起
        $(".iconTrees .zTrees-triangle-r").click(function () {
            $.fn.zTree.getZTreeObj("treeSelectResource").expandAll(false);
        });
        //刷新
        $(".iconTrees .zTrees-refresh").click(function () {
            resZtrees();
        });
    })
</script>
</body>
</html>